<%@ page language="java" pageEncoding="utf-8"%>
<%@ taglib prefix="s" uri="/struts-tags" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<jsp:include page="../common/cts.jsp"></jsp:include>
<s:if test="work.item.type == 1">
	<s:set var="typeTxt" value="'FCL'"/>
	<s:set var="orgTxt" value="'出发地'"/>
	<s:set var="polTxt" value="'装货港'"/>
	<s:set var="tpTxt" value="'中转港'"/>
	<s:set var="podTxt" value="'卸货港'"/>
	<s:set var="desTxt" value="'目的地'"/>
</s:if>
<s:elseif test="work.item.type == 2">
	<s:set var="typeTxt" value="'LCL'"/>
	<s:set var="orgTxt" value="'出发地'"/>
	<s:set var="polTxt" value="'装货港'"/>
	<s:set var="tpTxt" value="'转拼港'"/>
	<s:set var="podTxt" value="'卸货港'"/>
	<s:set var="desTxt" value="'目的地'"/>
</s:elseif>
<s:elseif test="work.item.type == 3">
	<s:set var="typeTxt" value="'AIR'"/>
	<s:set var="orgTxt" value="'出发地'"/>
	<s:set var="polTxt" value="'起飞港'"/>
	<s:set var="tpTxt" value="'中转港'"/>
	<s:set var="podTxt" value="'到达港'"/>
	<s:set var="desTxt" value="'目的地'"/>
</s:elseif>
<s:elseif test="work.item.type == 4">
	<s:set var="typeTxt" value="'EXPRESS'"/>
	<s:set var="orgTxt" value="'出口国'"/>
	<s:set var="desTxt" value="'进口国'"/>
</s:elseif>
<s:elseif test="work.item.type == 5">
	<s:set var="typeTxt" value="'TRUCKING'"/>
	<s:set var="orgTxt" value="'出发地'"/>
	<s:set var="desTxt" value="'目的地'"/>
</s:elseif>
<s:else>
	<s:set var="typeTxt" value="'其它'"/>
	<s:set var="orgTxt" value="'地点'"/>
</s:else>
<s:set var="isCreate" value="#request.isCreate != null ? #request.isCreate : #parameters.isCreate[0]" />
<s:if test="#isCreate == 1">
	<s:set var="workStatusTxt" value="'订单创建'"/>
</s:if>
<s:else>
	<s:set var="workStatusTxt" value="'订单编辑'"/>
</s:else>
<html>
  <head>
    <title>订单</title>
	<link rel="stylesheet" href="${pageContext.request.contextPath}/cts/css/style.css" type="text/css" />
	<link rel="stylesheet" href="${pageContext.request.contextPath}/cts/css/jNice.css" type="text/css" />
	<script type="text/javascript" src="${pageContext.request.contextPath}/cts/js/jquery.js"></script>
	<script type="text/javascript" src="${pageContext.request.contextPath}/cts/js/common.js"></script>
	<script type="text/javascript" src="${pageContext.request.contextPath}/cts/js/jquery.jNice.js"></script>
	<script type="text/javascript" src="${pageContext.request.contextPath}/cts/js/jquery.autoresize.js"></script>
	<script type="text/javascript" src="${pageContext.request.contextPath}/cts/js/validate.tips.js"></script>
	<script type="text/javascript" src="${pageContext.request.contextPath}/cts/js/jquery.bgiframe.js"></script>
	<script type="text/javascript" src="${pageContext.request.contextPath}/cts/js/popdiv.js"></script>
	<script type="text/javascript" src="${pageContext.request.contextPath}/cts/js/searchdata.js"></script>
	<script type="text/javascript" src="${pageContext.request.contextPath}/cts/js/My97DatePicker/WdatePicker.js"></script>
	<style>
		.jNice{font-size: 14px; color:#676767;}
		input, select{margin: 0; margin-right: 8px; vertical-align: middle; color:#676767;}
		.jNice input, .jNice select{width: 220px; padding-left:10px; _padding-left:0; font-size: 14px;}
		select.special {margin-right: -5px; padding-left:0; width: 55px; height: auto;}
		input.special{width: 86%; padding-left: 0; font-size: inherit;}
		.jNice .input_s{width:80px}
		.jNice .input_m{width:140px;}
		.jNice .input_xl{width:695px;}
		.jNice .input_xxl{width:720px;}
		
		.add_btn,.add_btn:visited{background:url(${pageContext.request.contextPath}/cts/images/add_1.png) no-repeat center; width: 32px; height: 33px; border: 0;
			text-decoration: none; display: inline-block; margin-left: 10px; line-height: 43px; _line-height: 46px;}
		.add_btn:active{background:url(${pageContext.request.contextPath}/cts/images/add_1_active.png) no-repeat center; width: 32px; height: 33px; border: 0;}
		.btn_info,.btn_info:visited{background:url(${pageContext.request.contextPath}/cts/images/info.png) no-repeat center; width: 32px; height: 33px; border: 0;
			text-decoration: none; display: inline-block; margin-left: 10px; margin-right:-20px; line-height: 43px; _line-height: 46px;}
		.btn_info:active{background:url(${pageContext.request.contextPath}/cts/images/info_active.png) no-repeat center; width: 32px; height: 33px; border: 0;}
		.btn_info_red,.btn_info_red:visited{background:url(${pageContext.request.contextPath}/cts/images/info_red_active.png) no-repeat center; width: 32px; height: 33px; border: 0;
			text-decoration: none; display: inline-block; margin-left: 10px; margin-right:-20px; line-height: 43px; _line-height: 46px;}
		.btn_ok,.btn_cancel,.jNice .btn_ok,.jNice .btn_cancel{background-image: url(${pageContext.request.contextPath}/cts/images/btn_ok.png); background-color: transparent;
			display: inline; border:0; width: 125px; height: 45px; padding-right: 20px; font-size: 14px; color:#676767; vertical-align: middle;}
		.btn_cancel,.jNice .btn_cancel{background-image: url(${pageContext.request.contextPath}/cts/images/btn_cancel.png);}
		.calendar{background: url('${pageContext.request.contextPath}/cts/images/calendar.png') no-repeat scroll 94% 3px;}
		
		.div_main{width:100%; height:100%; float:left;
			filter:progid:DXImageTransform.Microsoft.gradient(startcolorstr=#b2c85c,endcolorstr=#869f2a,gradientType=0);
			background:#b2c85c; /* 一些不支持背景渐变的浏览器 */
		    background:-moz-linear-gradient(top, #b2c85c, #869f2a);
		    background:-webkit-gradient(linear, 0 0, 0 bottom, from(#b2c85c), to(#869f2a));
		    background:-o-linear-gradient(top, #b2c85c, #869f2a);}
		.div_left{width: 200px; float:left; _height:100%;}
		.setp_logo{width: 100%; height:78px; text-align: center; 
			background: url(${pageContext.request.contextPath}/cts/images/line_bottom.png) repeat-x bottom;}
		.div_right{width: 773px; _height:100%; float:right; padding-left:25px; padding-bottom:170px; border-left:1px solid #798D2C; margin-left:-1px;
			background-image: url(${pageContext.request.contextPath}/cts/images/detail_bg.png);}
		.setp_top{width: 100%; height:78px; margin-left:-45px; padding-left:45px; line-height: 78px; font-size: 18px;
			background: url(${pageContext.request.contextPath}/cts/images/line_bottom.png) repeat-x bottom;}
		.setp_top_btn{float: right; margin-right: 10px; _position: relative; _top: 20%}
		.setp_main{margin-top: 20px}
		
		.step{display:block; float:right; margin: 0; margin-top:5px; width: 165px; height:40px; _position:relative;
			line-height:42px; font-size: 18px; color:white; text-align: right; padding-right: 20px; text-decoration: none;}
		.step<s:property value="#request.step" />{background-image: url(${pageContext.request.contextPath}/cts/images/detail_bg.png); color:#676767; border-bottom:1px solid #556028; border-left:1px solid transparent;
			-moz-border-top-left-radius: 6px;-webkit-border-top-left-radius: 6px; border-top-left-radius: 6px;
			-moz-border-bottom-left-radius: 6px;-webkit-border-bottom-left-radius: 6px; border-bottom-left-radius: 6px;}
			
		.stress{color:#FD7102}
		.stress_bg{background-color: #F9F1CD;}
		.table td{padding-left: 8px;}
		.table td table{margin-left: -8px;}
		.title td{padding-left: 0; padding-top: 10px; padding-bottom: 5px;}
		.table .add_btn,.table .btn_info,.table .btn_info_red{height: 44px;}
		
		.fee_border{width:94%; border:1px dashed #676767; padding: 10px; margin-top: 25px;}
		.fee_place{color:#C1425F; font-size: 18px; font-style: italic;}
		.fee_add_div{float: right; line-height: 18px;}
		.fee_add{background:url(${pageContext.request.contextPath}/cts/images/fee_add.png) no-repeat center right; height: 20px; border: 0; padding-right:18px;
			display: inline-block; line-height: 18px; color:#869717; font-size: 12px;}
		.fee_edit{background:url(${pageContext.request.contextPath}/cts/images/fee_edit.png) no-repeat center; width:20px; height: 20px; border: 0;
			display: inline-block; margin-right: 5px; line-height: 18px; color:#869717;}
		.fee_ok{background:url(${pageContext.request.contextPath}/cts/images/fee_ok.png) no-repeat center; width:20px; height: 20px; border: 0;
			display: inline-block; margin-right: 5px; line-height: 18px; color:#869717;}
		.fee_del{background:url(${pageContext.request.contextPath}/cts/images/fee_del.png) no-repeat center; width:20px; height: 20px; border: 0;
			display: inline-block; line-height: 18px; color:#869717;}
		.fee_ok_right{background:url(${pageContext.request.contextPath}/cts/images/fee_ok.png) no-repeat center right; height: 20px; border: 0; padding-right:18px;
			display: inline-block; line-height: 18px; color:#869717; font-size: 12px;}
		
		.flie_div,.flie_active_div{width: 72px; text-align: center; float:left; cursor:pointer}
		.flie_active_div{background: url(${pageContext.request.contextPath}/cts/images/flie_active.png) no-repeat center top;}
		.flie_1,.flie_2,.flie_3,.flie_10,.flie_11,.flie_12,.flie_13,.flie_14,.flie_15{width: 72; height: 53px; margin-bottom:-3px;}
		.flie_1{background: url(${pageContext.request.contextPath}/cts/images/flie_1.png) no-repeat center;}
		.flie_2{background: url(${pageContext.request.contextPath}/cts/images/flie_2.png) no-repeat center;}
		.flie_3{background: url(${pageContext.request.contextPath}/cts/images/flie_3.png) no-repeat center;}
		.flie_10{background: url(${pageContext.request.contextPath}/cts/images/file_doc.png) no-repeat center;}
		.flie_11{background: url(${pageContext.request.contextPath}/cts/images/file_img.png) no-repeat center;}
		.flie_12{background: url(${pageContext.request.contextPath}/cts/images/file_pdf.png) no-repeat center;}
		.flie_13{background: url(${pageContext.request.contextPath}/cts/images/file_ppt.png) no-repeat center;}
		.flie_14{background: url(${pageContext.request.contextPath}/cts/images/file_rar.png) no-repeat center;}
		.flie_15{background: url(${pageContext.request.contextPath}/cts/images/file_xls.png) no-repeat center;}
		
		.tag_div{font-size:14px; float:left; margin-right:8px; background-color:#999; color:black; padding:0 8px 0 8px; height: 40px; line-height:40px; 
			-moz-border-radius: 10px;-webkit-border-radius: 10px; border-radius: 10px; text-align: center;}
		.del_tag{float: right; _float:none; width: 24px; height: 24px; margin:-10px -18px auto -6px; _margin:-18px -60px -22px -4px; display:none; z-index:5px; cursor:pointer;
			background: url(${pageContext.request.contextPath}/cts/images/tips_error.gif) no-repeat center; position: relative;}
		.tag_td .jNiceWrapper{display:none;}
		
		.boxAmount_txt{width: 30px; border:1px solid; padding-left: 0px;}
		<s:if test="#request.employee.auth5 != 1" >
			.table .add_btn,.add_btn{display:none;}
		</s:if>
	</style>
	<script>
		var step = '<s:property value="#request.step"/>';
		var isCreate = '<s:property value="#isCreate" />';
		$(function(){
			$('.div_left,.div_right').css('min-height',($('.div_main').parent().height() - 170)+'px');
			var tips = '<s:property value="#request.tips" />';
			if(tips == '1'){
				alert('请先完成<s:property value="#typeTxt" escape="false" />');
			}
			if(isCreate == 1){
				if($('.div_left .step').length != step){
					$('.setp_top_btn .btn_ok').val('下一步');
				}else{
					$('.setp_top_btn .btn_ok').val('完成');
				}
				$('.setp_top_btn .btn_cancel').val('上一步');
			}else{
				$('.setp_top_btn .btn_ok').val('保存');
				$('.setp_top_btn .btn_cancel').val('返回浏览页');
			}
			if(isCreate == 1){
				$('.div_left .step').css('cursor','default');
			}
		})
		window.onresize = function(){
			$('.div_left,.div_right').css('min-height',($('.div_main').parent().height() - 170)+'px');
		}
		//添加访客
		function addEmployee(txt){
			var auth5 = '<s:property value="#request.employee.auth5" />';
			if(auth5 != '1') return;
			var url = "findSingleEmployee.action?type=1&noplay=true&ntcpyId=<s:property value="work.company.id" />&setTxtId="+txt+"Id&setNickname="+txt;
			openPopDiv( 'addEmployee' , url ,  200);
		}
		
		//取消
		function cancelWork(){
			//TODO 传列表查询参数
			//window.location.href = "searchWork";
			if(window.opener){
				window.opener.location.reload();
			}
			window.location.href="${pageContext.request.contextPath}/cts/workDetail?id="+$("#workId").val();
		}
		
		function nextStep(){
			if(isCreate != 1){
				alert('保存成功');
				return;
			}
			var isReturn='<s:property value="#request.isReturn"/>';
			
			if(step==7 && isReturn==1){
				window.location.href="${pageContext.request.contextPath}/cts/workDetail?id="+$("#workId").val();
			}
			
			if(step && step != ''){
				var url = $('#a_step_' + step).next().attr('href');
				if(!url || url == ''){
					cancelWork();
				}else{
					window.location.href = url + '&isCreate=' + isCreate;
				}
			}
		}
		function prevStep(){
			if(isCreate != 1){
				cancelWork();
				return;
			}
			if(step && step != ''){
				var url = $('#a_step_' + step).prev().attr('href');
				if(!url || url == ''){
					cancelWork();
				}else{
					window.location.href = url + '&isCreate=' + isCreate;
				}
			}
		}
		function checkWorkId(){
			return $("#workId").val() != '' && isCreate != 1;
		}
		//保存或修改一行数据
		function saveOrEditTr(obj, url, fn){
			if(obj.className=="fee_ok"){
				var parent = $(obj).parents('tr:first');
				var hideBox = function(){
					parent.find('input:text,select').each(function(){
						var spanId = this.id+'Span'
						var span = '';
						if(this.tagName.toUpperCase() == 'SELECT'){
							span = this.options[this.selectedIndex].text;
						}else{
							span = this.value == '' ? '&nbsp;' : this.value;
						}
						span = "<span id='"+spanId+"' title='"+span+"'>"+span+"</span>"
						$(this).after(span);
						$(this).hide();
					})
					obj.className = 'fee_edit';
				}
				if(!firstLoad && url && url != ''){ //刚加载不用验证
					var validate = true;
					parent.find('input:text,select').each(function(){
						var result = true;
						if(this.tagName.toUpperCase() == 'SELECT'){
							result = this.value != 0 || $(this).attr("pass") == 1;
							if(!result){
								validate = false;
								errorCss(this)
							}else{
								normalCss(this)
							}
						}else if(typeof this.startValidateTips == 'function'){
							result = this.startValidateTips();
							if(!result){
								validate = false;
								errorCss(this)
							}else{
								normalCss(this)
							}
						}
					})
					if(!validate) return ;
					var param = parent.find('input,select').serialize()+'&workId='+$('#workId').val();
					$.post(url, param, function(result){
						if(fn(result)){
							hideBox();
						}
					})
				}else{
					hideBox();
				}
			}else{
				$(obj).parents('tr:first').find('input:text,select').each(function(){
					var spanId = this.id+'Span'
					$(this).nextAll('#'+spanId).first().remove();
					$(this).show();
				})
				obj.className = 'fee_ok';
			}
		}

	</script>
  </head>
  <body class="body_bg" >
  	<div style="width: 998px; min-height:100%; _height:100%; margin: 0 auto; color:#676767; text-align: left;">
  		<div class="div_main">
	  		<div class="div_right">
	  			<form id="workForm" name="workForm" <s:if test="#request.step < 3 || #request.step == 4">class="jNice"</s:if> method="post" autocomplete="off">
	  				<input type="hidden" id="workId" name="work.id" value="<s:property value="work.id" />" />
	  				<input type="hidden" id="companyId" name="work.company.id" value="<s:property value="work.company.id" />" />
	  				<input type="hidden" id="itemId" name="work.item.id" value="<s:property value="work.item.id" />" />
	  				<input type="hidden" id="type" name="type" value="<s:property value="work.item.type" />" />
	  				
	  				<s:if test="#request.step == 1">
	  					<jsp:include page="workstep1.jsp"></jsp:include>
	  				</s:if>
	  				<s:elseif test="#request.step == 2">
	  					<jsp:include page="workstep2.jsp"></jsp:include>
	  				</s:elseif>
	  				<s:elseif test="#request.step == 3">
	  					<jsp:include page="workstep5.jsp"></jsp:include>
	  				</s:elseif>
	  				<s:elseif test="#request.step == 4">
	  					<jsp:include page="workstep3.jsp"></jsp:include>
	  					<s:if test="#request.allWorkItem.size() > 0">
  							<jsp:include page="workstep4.jsp"></jsp:include>
  						</s:if>
	  				</s:elseif>
	  				<s:elseif test="#request.step == 5">
	  					<s:if test="(work.id == null || work.id == 0) || #c_employeeid == work.employee.id || #cts_employeetype == 2">
		  					<jsp:include page="workstep6.jsp"></jsp:include>
	  					</s:if>
	  				</s:elseif>
	  				<s:elseif test="#request.step == 6">
	  					<jsp:include page="workstep7.jsp"></jsp:include>
	  				</s:elseif>
  				</form>
	  		</div>
	  		<div class="div_left">
	  			<div class="setp_logo">&nbsp;<br />
	  				<img src="${pageContext.request.contextPath}/cts/images/cargoTracingSystem2.png"/>
	  			</div>
	  			<a id="a_step_1" onclick="return checkWorkId()" href="${pageContext.request.contextPath}/cts/addOrEditWork?step=1&workId=<s:property value="work.id" />" class="step step1">关于</a>
	  			<a id="a_step_2" onclick="return checkWorkId()" href="${pageContext.request.contextPath}/cts/addOrEditWork?step=2&workId=<s:property value="work.id" />" class="step step2">货物</a>
	  			<a id="a_step_3" onclick="return checkWorkId()" href="${pageContext.request.contextPath}/cts/addOrEditWork?step=3&workId=<s:property value="work.id" />" class="step step3">费用</a>
  				<a id="a_step_4" onclick="return checkWorkId()" href="${pageContext.request.contextPath}/cts/addOrEditWork?step=4&workId=<s:property value="work.id" />" class="step step4">操作</a>
	  			<s:if test="(work.id == null || work.id == 0) || #c_employeeid == work.employee.id || #cts_employeetype == 2">
		  			<a id="a_step_5" onclick="return checkWorkId()" href="${pageContext.request.contextPath}/cts/addOrEditWork?step=5&workId=<s:property value="work.id" />" class="step step5">作业团队</a>
	  			</s:if>
	  			<a id="a_step_6" onclick="return checkWorkId()" href="${pageContext.request.contextPath}/cts/addOrEditWork?step=6&workId=<s:property value="work.id" />" class="step step6">文件</a>
	  		</div>
  		</div>
  	</div>
  	<!-- 添加访客 -->
	<div id="addEmployee" name="n_addEmployee" class="popdiv_inner" style="width:300px;">
		<div class="popdiv_inner_outter"></div>
		<div class="popdiv_close"></div>
		<div class="popdiv_handle" title="鼠标左键按住可拖动">公司访客</div>
		<div class="popdiv_content" style="height:300px;text-align: center;"></div>
	</div>
	<!-- 箱量柜号 -->
	<div id="boxAmountDiv" class="popdiv_inner" style="width:760px">
		<div class="popdiv_inner_outter"></div>
		<div class="popdiv_close" onclick="$('.tips_div').hide()"></div>
		<div class="popdiv_handle" style="font-size: 12px;" title="鼠标左键按住可拖动">
			<s:if test="work.item.type==1">箱量/柜号</s:if>
			<s:elseif test="work.item.type==2">柜号</s:elseif>
		</div>
		<div class="popdiv_content">
		</div>
	</div>
  </body>
</html>
